/*
 *  detailsview.cpp
 *  Perceel
 *
 *  Created by Nicola Gigante on 12/05/08.
 *  Copyright 2008 Nicola Gigante. All rights reserved.
 *
 */

#include "detailsview.h"

DetailsView::DetailsView(QWidget *parent) : QGroupBox(parent)
{
	setupUi(this);
	setTitle(tr("Details"));
}

void DetailsView::setDetail(QString key, QString detail)
{
	map.insert(key, detail);
	updateWidgets();
}

void DetailsView::removeDetail(QString key)
{
	map.remove(key);
	updateWidgets();
}

void DetailsView::setDetails(const QMap<QString, QString> &details)
{
	QMapIterator<QString, QString> i(details);
	while (i.hasNext())
	{
		i.next();
		map[i.key()] = i.value();
	}
	updateWidgets();
}

void DetailsView::updateWidgets()
{
	QString str;
	QMapIterator<QString, QString> i(map);
	while (i.hasNext())
	{
		i.next();
		str += QString("<b>%1</b>: %2<br/>").arg(i.key(), i.value());
	}

	label->setText(str);
}
